package com.boco.fengke.timelinetest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    private ListView listView;
    private TimeLineAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listView = (ListView)findViewById(R.id.timelineList);
        adapter = new TimeLineAdapter(this,getData());
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                adapter.setHighlight(position);
                adapter.notifyDataSetChanged();
            }
        });
    }

    private List<Map<String,String>> getData(){
        List<Map<String,String>> list = new ArrayList<Map<String,String>>();
        Map<String,String> map = new HashMap<String,String>();
        map.put("Status","订单提交成功");
        map.put("Time","2016-05-23 13:00");
        list.add(map);

        map = new HashMap<String,String>();
        map.put("Status","付款成功");
        map.put("Time", "2016-05-23 14:00");
        list.add(map);

        map = new HashMap<String,String>();
        map.put("Status","等待医生审阅");
        map.put("Time","2016-05-24 15:00");
        list.add(map);

        map = new HashMap<String,String>();
        map.put("Status","阅片");
        map.put("Time","2016-05-24 16:00");
        list.add(map);

        return list;
    }
}
